package com.androidtest3d.scene;

import java.util.ArrayList;
import java.util.List;

import javax.microedition.khronos.opengles.GL10;

/**
 * Android Game Tutorial Project.
 *
 * Copyright (C) 2011  Philipp Jenke
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * Representation of a generic node in the scene graph
 */
public class Node {

	/**
	 * Container for the child nodes.
	 */
	private List<Node> children = new ArrayList<Node>();

	/**
	 * Add a new child.
	 * 
	 * @param child
	 */
	public void addChild(Node child) {
		children.add(child);
	}

	/**
	 * Initialize the node object.
	 */
	public void init() {
		for (int i = 0; i < children.size(); i++) {
			children.get(i).init();
		}
	}

	/**
	 * Render 3D content of the node.
	 * 
	 * @param gl
	 */
	public void draw(GL10 gl) {
		for (int i = 0; i < children.size(); i++) {
			children.get(i).draw(gl);
		}
	}

}
